package tt.lab.designparttern.observer;

import java.util.ArrayList;
import java.util.List;

public class Subject {
	private String name;
	private List<Observer> observers = new ArrayList<Observer>();
	public void addObserver(Observer observer){
		this.observers.add(observer);
	}
	public void removeObserver(Observer observer){
		this.observers.remove(observer);
	}
	private void notifyObservers(String name){
		for(Observer observer: observers){
			observer.update(name);
		}
	}
	public void setName(String name) {
		this.name = name;
		notifyObservers(name);
	}
	public String getName() {
		return name;
	}
	
	
	
}
